home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
st80_pr4.lha
/
st80_pre4
/
Foible
/
foible
/
FoibleBinIO-PP.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
4KB
|
126 lines
'From Objectworks for Smalltalk-80(tm), Version 2.5 of 29 July 1989 on 16 April 1990 at 8:45:08 pm'!
!Tool methodsFor: 'layout messages'!
open
"Ask for a filename, and make the model the result of reading
the structure in that file"
| aName aFoibleProgram |
aName _ (FillInTheBlank request: 'Open what layout file?') asFilename.
aName = '' ifTrue: [^nil].
aName exists ifFalse: [^PopUpNotifier message: aName , ' does not exist.'].
Cursor wait show.
aFoibleProgram _ FoibleProgram readStructureFromFile: aName.
model cursor show.
view superView class openOn: aFoibleProgram!
save
"Ask for a filename, and save the model in that file"
| aName result |
aName _ (FillInTheBlank request: 'Save in what file?' initialAnswer: self program name,'.stbin').
aName = '' ifTrue: [^nil].
aName _ aName asFilename.
aName exists
ifTrue:
[result _ BinaryChoice message: 'File ' , aName , ' already exists.
Do you want to overwrite it?'.
result ifFalse: [^nil]].
Cursor wait show.
self program storeStructureOnFile: aName.
model cursor show! !
Model subclass: #FoibleProgram
instanceVariableNames: 'name managers '
classVariableNames: ''
poolDictionaries: ''
category: 'Foible'!
!FoibleProgram methodsFor: 'accessing'!
managers
"return the managers"
^managers! !
!FoibleProgram methodsFor: 'saving'!
storeStructureOnFile: aFileName
"Uses binary storage save a copy of the Foible program; don't save
dependents with it. Breaks the managers dependents before saving
and restores them afterwards."
| aFoibleProgram dependentsList deps |
aFoibleProgram _ self copy. "get a copy without dependents."
managers _ aFoibleProgram managers.
dependentsList _ OrderedCollection new.
managers do:
[:aManager |
dependentsList add: aManager dependents.
aManager breakDependents].
BinaryStorage put: aFoibleProgram onFileNamed: aFileName.
managers do:
[:aManager |
deps _ dependentsList at: (managers indexOf: aManager).
deps do: [:aDependent | aManager addDependent: aDependent]]! !
!FoibleProgram methodsFor: 'public binary storage'!
storeBinary
"Writes a description of the receiver into a file, in a way that allows
the object's structure to be reconstructed from the file's contents."
| fileName savedCursor |
fileName _ FileDirectory
requestFileName: 'Store binary on which file name?'
default: (self name, '.stbin')
version: #any
ifFail: [^nil].
savedCursor _ Cursor currentCursor.
Cursor wait show.
self storeStructureOnFile: fileName.
savedCursor show.! !
!FoibleProgram class methodsFor: 'instance creation'!
readStructureFromFile: aFileName
"Read from a disk file a saved FoibleProgram whose instance variable
'managers' is initialized to be an OrderedCollection containing
one (or more) FoibleManagers. The FoibleProgram must have been
saved with ObjectWorks BOSS."
| newFoibleProgram |
newFoibleProgram _ BinaryStorage fromFileNamed: aFileName.
^newFoibleProgram! !
!ToolBenchView class methodsFor: 'instance creation'!
openProgram
"Open an existing program; saved as a binary"
"ToolBenchView openProgram"
| aFileName |
aFileName _ FileDirectory
requestFileName: 'Which layout do you want to open?'
default: '*.stbin'
version: #any
ifFail: [^nil].
aFileName asFilename exists ifFalse: [^PopUpNotifier message: aFileName , ' does not exist.'].
self openOn: (FoibleProgram readStructureFromFile: aFileName)!
openProgram: aName
"Open an existing program saved as a binary"
"ToolBenchView openProgram: <name>"
| aFileName |
aFileName _ aName asFilename.
aFileName exists ifFalse: [^PopUpNotifier message: aFileName asString , ' does not exist.'].
self openOn: (FoibleProgram readStructureFromFile: aFileName)! !